<template>

  <a-modal v-model:visible="LAYER.visible" :title="LAYER.title" :width="1200" :ok-text="LAYER.okText"
           :align-center="LAYER.alignCenter" :top="LAYER.top"
           :footer="false"
           :closable="LAYER.closable" :unmount-on-close="LAYER.unmountOnClose"
           :mask-closable="LAYER.maskClosable" :esc-to-close="LAYER.escToClose" :ok-loading="LAYER.okLoading"
           :on-before-ok="onSubmit" @cancel="onClose()">


    <a-descriptions bordered :column="3" :size="'large'">
      <a-descriptions-item label="操作员"> {{ props.record.operator }}</a-descriptions-item>
      <a-descriptions-item label="客户端IP">{{ props.record.ip }}</a-descriptions-item>
      <a-descriptions-item label="所在包名">{{ props.record.packageName }}</a-descriptions-item>
      <a-descriptions-item label="执行类名">{{ props.record.className }}</a-descriptions-item>
      <a-descriptions-item label="日志标题">{{ props.record.event }}</a-descriptions-item>
      <a-descriptions-item label="端操作系统">{{ props.record.os }}</a-descriptions-item>
      <a-descriptions-item label="请求浏览器">{{ props.record.browser }}</a-descriptions-item>

      <a-descriptions-item label="请求类型">{{ props.record.requestMethod }}</a-descriptions-item>
      <a-descriptions-item label="操作时间"  >{{ props.record.actionTime }}</a-descriptions-item>
      <a-descriptions-item label="请求路径" :span="3">{{ props.record.requestUrl }}</a-descriptions-item>
      <a-descriptions-item label="请求参数" :span="3">
        <a-textarea :disabled="true" :default-value="props.record.requestParam"  :auto-size="{minRows:3,maxRows:5}" > </a-textarea>
       </a-descriptions-item>
    </a-descriptions>

  </a-modal>

</template>
<script lang="ts" setup>

import { ref} from "vue";
import {LocalModal} from "@/libs/core";


const props = defineProps({
  record: {type: Object, required: true}
})
const emit = defineEmits(['close'])
const formRef = ref(null)
const isUpdate = props.record?.value !== undefined





const title = isUpdate ? '修改字典项' : '操作记录详情'
const service = new LocalModal(emit).setMD(title, '保存设置', 350)
const {LAYER, lockMd, unLockMd} = service

const onClose = () => {
  LAYER.visible = false
  emit('close', 'NONE')
}


const onSubmit = async () => {
  lockMd()
  const err = await formRef.value.validate();
  if (err !== undefined) return false
  lockMd()

  unLockMd()
}



</script>

